package org.cigo.fworld;

import org.cigo.fworld.R;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

public class BaseActivity extends Activity {
	
	@Override  
    public void onCreate(Bundle savedInstanceState) {  
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);  
        super.setContentView(R.layout.base_activity); 
    }
	
	/*
	 * set main content
	 */
	@Override
	public void setContentView(int layoutResID){
		LinearLayout llContent = (LinearLayout) findViewById(R.id.llMainContent);
		LayoutInflater inflater = (LayoutInflater) getSystemService(  
                Context.LAYOUT_INFLATER_SERVICE);  
        View v = inflater.inflate(layoutResID, null);  
        llContent.addView(v);
	}	
	
	@Override
	public void setTitle(CharSequence title){
		TextView tv = (TextView) findViewById(R.id.txBarTitle1);  
        if (null != tv) {  
            tv.setText(title);   
        } 
	}
	
	public void setTopBannerVisibility(boolean visibility){
		LinearLayout llTopBanner = (LinearLayout)findViewById(R.id.llTopBanner);
		if(null != llTopBanner){
			int vv =visibility ? View.VISIBLE : View.GONE;
			llTopBanner.setVisibility(vv);
		}
	}
	
	public void hideButtonRight(boolean isHide){
		Button btn = getButtonRight();
		if(null != btn){
			int visibility =isHide ? View.INVISIBLE : View.VISIBLE;
			btn.setVisibility(visibility);
		}
	}
	
	public void hideButtonLeft(boolean isHide){
		Button btn = getButtonLeft();
		if(null != btn){
			int visibility =isHide ? View.INVISIBLE : View.VISIBLE;
			btn.setVisibility(visibility);
		}
	}
	
	public Button getButtonRight(){
		return (Button) findViewById(R.id.btRight);  
	}
	
	public Button getButtonLeft(){
		return (Button) findViewById(R.id.btLeft);  
	}
}
